#include<iostream>
using namespace std;
const int N = 1e4 + 10;
int main()
{
	int n, m, key;
	int arr1[N];
	int arr2[N];
	cin >> n >> m >> key;
	for (int i = 0; i < n; i++) {
		cin >> arr1[i];
	}
	for (int i = 0; i < m; i++) {
		cin >> arr2[i];
	}
	int ansi = -1, ansj = -1;
	for (int i = 0, j = m - 1; i < n, j >= 0; i++) {
		while (arr1[i] + arr2[j] > key) {
			j--;
		}
		if (arr1[i] + arr2[j] == key) {
			ansi = i + 1;
			ansj = j + 1;
			break;
		}
	}
	cout << ansi << " " << ansj << endl;
	return 0;
}